<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>KityMinder Example</title>

    <link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
    <link rel="stylesheet" href="src/kityminder.css" rel="stylesheet">

    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
        }

        #minder-view {
            position: absolute;
            border: 1px solid #ccc;
            left: 10px;
            top: 10px;
            bottom: 10px;
            right: 10px;
            width: 100%;
            height: 100%;
        }
    </style>

    <script type="text/javascript" src="node_modules/kity/dist/kity.js"></script>
</head>
<body>
    <div id="minder-view">
        
    </div>
    <img id="minder-img">
    <script id="minder-json" type="application/kityminder" minder-data-type="json">
    {
        "template":"custom",
        "theme":"custom-blue",
        "dx":100,
        "dy":100,
        "root": {
            "data": {
                "text": "总成",
                "nodeType":1
            },
            "children": [
                { 
                    "data": { "text": "OP10 - 电机组装", "nodeType":2, "direction":"right" },
                    "children": [
                        {
                            "data": { "text": "OP1010", "nodeType":2, "direction":"right", "color":"#3CB371" },
                            "children": [
                                {
                                    "data": { "text": "FE：AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "nodeType":2,"direction":"right", "color":"#3CB371"  },
                                    "children": [
                                {"data": { "text": "FE：AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "nodeType":2,"direction":"right", "color":"#3CB371"  }}
                            ]
                                }
                            ]
                        },
                        {
                            "data": { "text": "电机功能：电能转化机械能", "nodeType":3, "direction":"down", "color":"#3CB371" },
                            "children": [
                                {"data": { "text": "FE：AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "direction":"down", "color":"#FF3030" }}
                            ]
                        },
                        {
                            "data": { "text": "最终功能：车窗能够上升下降", "direction":"down", "color":"#3CB371" },
                            "children": [
                                {"data": { "text": "FE：BBB", "direction":"down", "color":"#FF3030" }}
                            ]
                        },
                        {
                            "data": { "text": "最终功能：车窗能够上升下降", "direction":"down", "color":"#3CB371" },
                            "children": [
                                {"data": { "text": "FE：BBB", "direction":"down", "color":"#FF3030" }}
                            ]
                        }
                    ]
                },{
                    "data": { "text": "壳体", "nodeType":2, "direction":"right"},
                    "children": [
                        {
                            "data": { "text": "功能12222222222222222222222", "nodeType": 4,"direction":"down" },
                            "children": [
                                {
                                    "data": { "text": "失效模式", "nodeType": 5,"direction":"down" },
                                    "children": [
                                        {
                                            "data": { "text": "FC：失效原因", "nodeType": 6,"direction":"down" },
                                            "children": [
                                                {"data": { "text": "PC：预防措施", "nodeType": 8,"direction":"down" }},
                                                {"data": { "text": "DC：探测措施", "nodeType": 9,"direction":"down" }}
                                            ]
                                        }
                                    ]
                                }
                            ]
                        },{
                            "data": { "text": "壳体-驻车机构", "nodeType":10, "direction":"down" }
                        },{
                            "data": { "text": "壳体-电机", "nodeType":11, "direction":"down" }
                        }
                    ]
                },{
                    "data": { "text": "壳体2", "nodeType":2, "direction":"right"},
                    "children": [
                        {
                            "data": { "text": "功能1","topTitle":"功能功能AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "nodeType":4, "direction":"down" }
                        },
                        {
                            "data": { "text": "功能1", "direction":"down"}
                        }
                    ]
                },{
                    "data": { "text": "功能", "nodeType":4, "direction":"down"}
                },{
                    "data": { "text": "失效影响", "nodeType":7, "direction":"down", "forceBorder":true}
                },{
                    "data": { "text": "一二", "nodeType":4, "direction":"down"}
                },{
                    "data": { "text": "左边", "nodeType":2, "direction":"left"},
                    "children": [
                        {
                            "data": { "text": "功能1","topTitle":"功能功能AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "nodeType":4, "direction":"down" }
                        },{
                            "data": { "text": "功能1","topTitle":"功能功能AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "nodeType":4, "direction":"down" }
                        },{
                            "data": { "text": "功能1","topTitle":"功能功能AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "nodeType":4, "direction":"down" }
                        },
                        {
                            "data": { "text": "功能1", "direction":"left", "nodeType":2}
                        }
                    ]
                },{
                    "data": { "text": "上面", "nodeType":4, "direction":"top"}
                }
            ]
        }
    }
    </script>
</body>

<!-- *************************** Module 形式加载引入 **************************** -->
<script type="text/javascript" src="node_modules/seajs/dist/sea-debug.js"></script>
<script type="text/javascript">
    /* global seajs */
    seajs.config({
        base: './src'
    });
    define('start', function(require) {
        var Minder = require('kityminder').Minder;

        // 创建 km 实例
        var km = window.km = new Minder({
            renderTo: '#minder-view',
            x: 500,
            y: 1000
        });
        var data = document.querySelector("#minder-json").textContent;
        km.importData("json", data);
        km.execCommand('Camera', km.getRoot(), 0);
        // setTimeout(() => {
        //     km.exportPng("abc");
        // }, 1000);
    });
    seajs.use('start');
</script>
</html>